Log unhandled exceptions to %LOCALAPPDATA%\Snipdeck\logs\unhandled.log#13
Merged
Conversation
Stuart hit a "Continue?" debugger dialog on launch and the exception detail evaporated — WinUI's default handler shows the dialog but doesn't log anywhere. Outside the debugger that same exception kills the process silently. Wire three handlers: - Application.UnhandledException (XAML-thread) - TaskScheduler.UnobservedTaskException - AppDomain.UnhandledException (for completeness; rarely fires in managed code but free to add) Each writes a formatted record — type, HRESULT for COMExceptions, the full message, source, stack, and recursively all inner exceptions — to %LOCALAPPDATA%\Snipdeck\logs\unhandled.log. Sets Handled=true so the app keeps running rather than dying; this matches the user's experience of clicking Continue. CrashLog.Write is best-effort: it cannot throw, even if DI isn't built, the path is locked, or disk is full. The log rotates at 5 MB to a .1 sibling so it can't grow unbounded. IPathProvider gains LogsDirectory; WindowsPathProvider implements it under %LOCALAPPDATA%\Snipdeck\logs\; FakePathProvider mirrors the addition for tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UnhandledExceptionplumbing — it shows the dialog but doesn't log anywhere, so the exception detail vanishes the moment you click through. Outside the debugger the same exception kills the process silently.App:Application.UnhandledException,TaskScheduler.UnobservedTaskException, andAppDomain.CurrentDomain.UnhandledException. Each writes a formatted record (type, HRESULT forCOMException, message, source, stack, recursive inner exceptions) to%LOCALAPPDATA%\Snipdeck\logs\unhandled.logand marks the exception handled so the app keeps running.CrashLog.Writeis best-effort: cannot throw, locks on a static for concurrent writes, rotates the file at 5 MB to a.1sibling so it can't grow unbounded.IPathProvidergainsLogsDirectory;WindowsPathProviderimplements it under%LOCALAPPDATA%\Snipdeck\logs\;FakePathProvidermirrors the addition for tests.Test plan
unhandled.logis populated with a usable stack trace.RelayCommandhandler, confirm the log captures it and the app continues running.🤖 Generated with Claude Code